package cn.kami.dao.proxy;

import java.util.List;

import cn.kami.dao.IBatteryDAO;
import cn.kami.dao.impl.BatteryDAOImpl;
import cn.kami.dbc.DatabaseConnection;
import cn.kami.factory.DatabaseConnectionFactory;
import cn.kami.vo.Battery;

public class BatteryDAOProxy implements IBatteryDAO {
	private DatabaseConnection dbc = null;
	private BatteryDAOImpl dao = null;
	public BatteryDAOProxy()throws Exception{
		this.dbc = DatabaseConnectionFactory.getOracleDatabaseConnection();
		this.dao = new BatteryDAOImpl(this.dbc.getConnection());
	}
	@Override
	public boolean isBattery(String batID) throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		try{
			flag = this.dao.isBattery(batID);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return flag;
	}
	@Override
	public boolean UpBattery(Battery bat) throws Exception {
		// TODO Auto-generated method stub
		boolean flag = false;
		try{
			flag = this.dao.UpBattery(bat);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return flag;
	}
	@Override
	public List<Battery> findBySta(String sta) throws Exception {
		// TODO Auto-generated method stub
		List<Battery> all = null;
		try{
			all = this.dao.findBySta(sta);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return all;
	}
	@Override
	public List<Battery> findByVer(String manuID, String version)
			throws Exception {
		// TODO Auto-generated method stub
		List<Battery> all = null;
		try{
			all = this.dao.findByVer(manuID,version);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return all;
	}
	@Override
	public List<Battery> findByBat(String type, String rateVoltage,
			int rateVolume) throws Exception {
		// TODO Auto-generated method stub
		List<Battery> all = null;
		try{
			all = this.dao.findByBat(type,rateVoltage,rateVolume);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return all;
	}
	@Override
	public List<Battery> findBySiName(String siName) throws Exception {
		// TODO Auto-generated method stub
		List<Battery> all = null;
		try{
			all = this.dao.findBySiName(siName);
		}catch(Exception e){
			throw e;
		}finally{
			this.dbc.close();
		}
		return all;
	}

}
